import { computed } from 'vue'
import { pick } from 'lodash-es'
import { TextComponentProps } from '../defaultProps'
// const useComponentCommon =<T extends {[key:string]:any }>(props: T , picks: string[]) => {
// 因为传入的vue3 组件中的props 设置Readonly 实现类型的兼容
const useComponentCommon =(props: Readonly<Partial<TextComponentProps>> , picks: string[]) => {
  const styleProps = computed(() => pick(props, picks))
  const handleClick = () => {
    if (props.actionType === 'url' && props.url) {
      window.location.href = props.url
    }
  }
  return {
    styleProps,
    handleClick
  }
}

export default useComponentCommon